<?php

declare(strict_types=1);

namespace App\Services;

use Hyperf\Di\Annotation\Inject;
use App\Exception\ApiException;
use App\Constants\ErrorCode;
use App\Model\PointsRanking;

class PointsRankingService extends BaseService
{

    public function ranking(array $params)
    {
        $level = ['S', 'A', 'B'];
        $limit = 10;

        $result = [];
        foreach($level as $val)
        {
            $pointsRanking = PointsRanking::query()->select('id','rank','user_id','month','points','level')->where('level', $val)->orderBy('rank', 'ASC')->limit($limit)->get()->toArray();
            $result[$val] = $pointsRanking;
        }

        return $result;
    }

}